﻿#pragma once


#include "SysBase.h"

namespace Base {

	// 封装下dx11 ??
	class Graphics
	{
	public:
		static Graphics* s_Graphics;
		Graphics();
		~Graphics();
		void Init(HWND hWnd, int width, int height);
		void Resize(int width, int height);

	public:

		ID3D11Device* GetDevice() const { return m_Device.Get(); }
		ID3D11DeviceContext* GetDeviceContext()const { return m_Context.Get(); }
		IDXGISwapChain* GetSwapChain()const { return m_SwapChain.Get(); }
		ID3D11RenderTargetView* GetRenderTargetView() { return m_Target.Get(); }
		ID3D11RenderTargetView** GetRenderTargetViewPPtr() { return m_Target.GetAddressOf(); }

		void SetClearColor(float r, float g, float b) {
			m_clearColor[0] = r;
			m_clearColor[1] = g;
			m_clearColor[2] = b;
		}
		void ClearBuffer();
		void Present();

	public:
		static Graphics* GetInstance() { return s_Graphics; }

	private:

		void SetViewPort(int leftX, int topY, int width, int height);

	private:

		ComPtr<ID3D11Device> m_Device;
		ComPtr<IDXGISwapChain> m_SwapChain;
		ComPtr<ID3D11DeviceContext> m_Context;
		ComPtr<ID3D11RenderTargetView> m_Target;

		ComPtr<ID3D11DepthStencilView> m_DepthStencilView;

		float m_clearColor[4];
	};
}

